using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vItemSoldQtyMap : EntityTypeConfiguration<vItemSoldQty>
    {
        public vItemSoldQtyMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Item, t.salesman, t.Type, t.Category, t.TypeId, t.CategId });

            // Properties
            this.Property(t => t.Item)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.salesman)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.Type)
                .IsRequired()
                .HasMaxLength(25);

            this.Property(t => t.Category)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.TypeId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.CategId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("vItemSoldQty");
            this.Property(t => t.Item).HasColumnName("Item");
            this.Property(t => t.salesman).HasColumnName("salesman");
            this.Property(t => t.Month).HasColumnName("Month");
            this.Property(t => t.year).HasColumnName("year");
            this.Property(t => t.Qty).HasColumnName("Qty");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.TypeId).HasColumnName("TypeId");
            this.Property(t => t.CategId).HasColumnName("CategId");
        }
    }
}
